home *** CD-ROM | disk | FTP | other *** search
- #include <stdio.h>
- #include <dos.h>
- #include <setjmp.h>
-
- int cbrk_handler(void);
- /* Buffer used by setjmp and longjmp */
- jmp_buf main_menu;
-
- main()
- {
- char input[80];
- int choice=0;
- /* Install the Control-Break handler */
- ctrlbrk(cbrk_handler);
-
- /* Call 'setjmp' to set up for returning to this
- * point after user presses Control-C */
- if(setjmp(main_menu) != 0)
- {
- /* Returning from a 'longjmp' -- print message */
- printf("Interrupted...\n");
- }
-
- /* This is the main menu of the program */
- printf("1 Loop endlessly...\n"
- "anything else to exit\n\n"
- "Enter Choice: ");
- gets(input);
- choice =atoi(input);
- switch(choice)
- {
- case 1: for(;;) printf("Looping...\n");
-
- default: exit(0);
- }
- }
- int cbrk_handler(void)
- {
- /* Return to the main menu */
- longjmp(main_menu, 1);
- }